﻿@using DocProcessingWorkflow.Models.MediaDefinition
@using DocProcessingWorkflow.Models.MediaStock
@using DocProcessingWorkflow.Resources.JobsAdmin
@model DocProcessingWorkflow.Models.JobsAdmin.JobsAdminMediaDefinitionsViewModel

<div>
  <table id="mediaDefinitionsList" class="table">
    <thead>
      <tr>
        <th class="col-md-1"></th>
        <th class="text-left col-md-6">@Index.PrintFiles</th>
        <th class="text-left col-md-1">@Index.Mailsorted</th>
        <th class="text-left col-md-1">@Index.Print</th>
        <th class="text-left col-md-1">@Index.PdfOnly</th>
        <th class="text-left col-md-2">@Index.Actions</th>
      </tr>
    </thead>
    <tbody>
      @foreach (MediaDefinitionViewModel mediaDefinition in Model.MediaDefinitions)
      {
        <tr class="media-definition-item" data-mediadefid="@mediaDefinition.MediaDefId" data-mailsortid="@mediaDefinition.MailSortSettingId">
          <td class="text-left">
            <a id="stockToggle_@mediaDefinition.MediaDefId" class="togglecollapse" data-toggle="collapse" data-target="#stockInfo_@mediaDefinition.MediaDefId"><span class="glyphicon glyphicon-plus-sign"></span></a>
          </td>
          <td class="queuename text-left">@mediaDefinition.QueueName</td>
          <td class="mailsorted text-left">@Html.CheckBox("mailsorted", mediaDefinition.MailSorted, new { disabled = "disabled" })</td>
          <td class="print text-left">@Html.CheckBox("print", mediaDefinition.Print, new { disabled = "disabled" })</td>
          <td class="pdfonly text-left">@Html.CheckBox("pdfonly", mediaDefinition.PdfOnly, new { disabled = "disabled" })</td>
          <td class="text-left">
            <div class="btn-group">
              <button type="button" class="btn btn-bbosaction dropdown-toggle" data-toggle="dropdown">@Index.Action <span class="caret"></span></button>
              <ul class="dropdown-menu" role="menu">
                <li><a data-toggle="modal" data-target="#stockAssignmentWindow" data-stocktype="Insert" href="#">@Index.ManageInserts</a></li>
                <li><a data-toggle="modal" data-target="#stockAssignmentWindow" data-stocktype="LaserStock" href="#">@Index.ManageTrays</a></li>
                <li><a data-toggle="modal" data-target="#stockAssignmentWindow" data-stocktype="Outer" href="#">@Index.ManageEnvelopes</a></li>
                <li><a data-toggle="modal" data-target="#mediaDefinitionAuditWindow" data-windowtitle="@Index.Audit" href="#">@Index.ShowAudit</a></li>
                <li><a class="edit-button" href="#">Edit</a></li>
              </ul>
            </div>
          </td>
        </tr>
        <tr>
          <td class="hiddenrow"></td>
          <td colspan="4" class="hiddenrow">
            <div id="stockInfo_@mediaDefinition.MediaDefId" data-target="stockToggle_@mediaDefinition.MediaDefId" class="collapse">
              <h4><strong>@Index.Inserts</strong></h4>
              @Html.Partial("_StockItems", mediaDefinition.Inserts)
              <h4><strong>@Index.Trays</strong></h4>
              @Html.Partial("_StockItems", mediaDefinition.Trays)
              <h4><strong>@Index.Envelopes</strong></h4>
              @Html.Partial("_StockItems", mediaDefinition.Envelopes)
            </div>
          </td>
        </tr>
      }
    </tbody>
  </table>

  <p id="mediaDefinitionsPagination" class="pagination col-md-12">
    <span id="totalNumberOfDocuments"><strong>@Index.TotalItems @Model.PagingInfo.TotalItems</strong></span> |
    <span id="showingDocumentsSpan">@Index.ShowingItems @Model.PagingInfo.StartRow - @Model.PagingInfo.EndRow</span> |

    @Html.Pager(
      Model.PagingInfo.ItemsPerPage, Model.PagingInfo.CurrentPage, Model.PagingInfo.TotalItems, new AjaxOptions()
    ).Options(x =>
        x
          .Action("JobsAdminAjax")
          .MaxNrOfPages(10))
  </p>
</div>